package main

import (
	"fmt"
	logsys "gitee.com/linbq-b7/go-log"
	"gitee.com/linbq-b7/go-log/example/dev"
	"gitee.com/linbq-b7/go-log/example/pro"
	"gitee.com/linbq-b7/go-log/example/test"
	"os"
	"time"
)

func main() {
	// 默认配置
	//logsys.InitDefault()

	// 自定义配置
	logsys.Init(GetRootPath() + "/example/log.xml")

	logsys.SetCallback(func(msg string) {
		fmt.Println("回调方法:", msg)
	})

	go func() {
		for {
			dev.PrintInfo()
			dev.PrintError()

			pro.PrintInfo()
			pro.PrintError()

			test.PrintInfo()
			test.PrintError()

			time.Sleep(time.Second)
		}
	}()

	select {}
}

func GetRootPath() string {
	dir, err := os.Getwd()
	if err != nil {
		panic(err)
	}
	return dir
}
